#!/bin/sh

if [ -n "$SUDO_USER" ]; then
    HOME_DIR=$(getent passwd "$SUDO_USER" | cut -d: -f6)
else
    HOME_DIR=~
fi

CONFIG_DIR="$HOME_DIR/.cache/linglong-builder"
CONFIG_DIR2="/var/lib/linglong/"
CONFIG_FILE="$CONFIG_DIR/config.yaml"
CONFIG_FILE2="$CONFIG_DIR2/config.yaml"

mkdir -p "$CONFIG_DIR"
mkdir -p "$CONFIG_DIR2"

cat <<EOF > "$CONFIG_FILE"
defaultRepo: old
repos:
  stable: https://mirror-repo-linglong.deepin.com
  old: https://repo-dev.cicd.getdeepin.org
version: 1
EOF

cat <<EOF > "$CONFIG_FILE2"
defaultRepo: old
repos:
  stable: https://mirror-repo-linglong.deepin.com
  old: https://repo-dev.cicd.getdeepin.org
version: 1
EOF